<template>
	<view>
		<div>
			<navitop> 
				<i class="iconfont icon-jiantou-copy" slot="left-slot" @click="outs"></i>
				<span slot="center-slot">{{data}}</span>
				<!-- <i class="iconfont icon-youcecaidan" slot="right-slot"  @click="tapPopup(data)"></i> -->
			</navitop>
		</div>
		
		<div class="detial" >
			<div style="background-color: #f0f0f0;" :style="'margin-top:' + nv_height" ></div>
				<div class="profit_icon">
					<v-tabs v-model="current" :scroll="scroll_one" line-height="0" pillsColor="#1296db" activeColor="#fff"
						:pills="true" :tabs="tab" @change="changeTab"></v-tabs>
				</div>
				<scroll-view class="staff_b" scroll-y="true" touch-action=none; :style='window_height'>
				<!-- 客户 -->
				<div class="profit_text" v-show="customer">
					<div v-for="(item,index) in dataSorce" class="profit_class">
						<div>
							<text>客户名称：{{item.companyName}}</text>
						</div>
						<div>
							<text>联系人姓名：{{item.createBy}}</text>
						</div>
						<div>
							<text>手机号码：{{item.mobile}}</text>
						</div>
						<div>
							<text>推荐等级：{{item.rn - 1}}</text>
						</div>
						<div>
							<text>注册日期：{{item.registDate}}</text>
						</div>
					</div>
					<div class="null_title" v-if="dataSorce == ''">
						<div>
							<i class="iconfont icon-empty iconcize"></i>
						</div>
						<div class="null_title_tow">
							没有更多数据
						</div>
					</div>
					<br><br><br><br><br><br>
				</div>
				
				 <!-- 小伙伴 -->
				<div class="profit_text" v-show="partner">
					<div v-for="(item,index) in dataSorce" class="profit_class">
						<div>
							<text>姓名：{{item.realName}}</text>
						</div>
						<div>
							<text>手机号：{{item.mobile}}</text>
						</div>
						<div>
							<text>注册日期：{{item.createDate}} </text>
						</div>
					</div>
					<div class="null_title" v-if="dataSorce == ''">
						<div>
							<i class="iconfont icon-empty iconcize"></i>
						</div>
						<div class="null_title_tow">
							没有更多数据
						</div>
					</div>
					<br><br><br><br><br><br>
				</div>
			</scroll-view>
		</div>
		<!-- 弹窗组件 -->
		<popus ref="alert">
			3
		</popus>

	</view>
</template>

<script>
	import popus from '@/uni_modules/uni-popup/components/uni-popup/uni-popup'
	import navtxt from '@/pages/common/index/detial/detialtxt'
	import navitop from '@/components/common/navi-top'
	import {getShareCrmList,getShareUserList} from '@/common/api/my/myapi.js'
	export default {
		components:{
			navitop,
			popus,
			navtxt
		},
		props:{
			data: {
				default: ''
			}
		},
		data(){
			return {
				window_height:'',
				alertWidth: '',
				tab: ['客户', '小伙伴'],
				current: 0,
				scroll_one: false, //设置tabs选项是否平铺 
				dataSorce: '',
				customer: false ,// 客户切换
				partner: false,	 // 小伙伴
				nv_height: '',	// 顶部导航栏高度
			}
		},
		mounted() {
			this.nv_height = uni.getSystemInfoSync().statusBarHeight + 75 + 'px';
			let _this = this;
			uni.getSystemInfo({
			    success: function (res) {
					_this.alertWidth = 'width:' + res.windowWidth + 'px;'
			    }
			});
		   const res = uni.getSystemInfoSync();
		   this.window_height = 'height:' + res.windowHeight + 'px;';
		   
		   this.http_list(0);
		   this.customer = true;
		},
		methods:{
			outs(){
				this.$emit('partner_colo',1)
			},
			// 切换
			changeTab(val){
				if(val == 0){
					this.http_list(0)
					this.partner = false;
				}
				if(val == 1){
					this.http_list(1)
					this.customer = false;
				}
				
			},
			http_list(val){
				if(val == 0){
					getShareCrmList({current: 1,size: 20,companyName: '',realName: ''}).then((rows) => {
						uni.showLoading({
							title: '加载中',
						})
						if(rows.code == 200){
							uni.hideLoading();
							this.customer = true;
							this.dataSorce = rows.data.records;
							for(let i in this.dataSorce){
								this.dataSorce[i]['registDate'] = this.dataSorce[i].registDate.substr(0,11)
							}
						}else{
							uni.hideLoading();
						}
					})
				}
				if(val == 1){
						uni.showLoading({
							title: '加载中',
						})
					getShareUserList({current: 1,size: 20,companyName: '',realName: ''}).then((rows) => {
						if(rows.code == 200){
							uni.hideLoading();
							this.partner = true;
							this.dataSorce = rows.data.records;
							for(let i in this.dataSorce){
								this.dataSorce[i]['createDate'] = this.dataSorce[i].createDate.substr(0,11)
							}
						}else{
							uni.hideLoading();
						}
						
					})
				}
			}
			
			
		}
	}
	
</script>

<style scoped lang="scss">
.detial {
	background-color: #fff;
}
.profit_icon {
	padding: 20rpx 0 0 0;
}
.profit_text {
	width: 100%;
	height: 100%;
	background-color: #fff;
	.profit_class {
		width: 95%;
		margin: auto;
		border-bottom: 1px solid #cacaca;
		padding-top: 20rpx;
		div {
			height: 50rpx;
		}
		text {
			padding: 0 0 0 30rpx;
		}
	}
}
</style>
